<?php
$q=$_GET["q"];
$hint='';
if($q!="")
{
include_once ("../Login/databaseconnection.php");
require_once ("../Login/config.php");
$result = mysql_query("SELECT * FROM resource Where Resource_Type='$q'");
if($row = mysql_fetch_array($result))
{
$id=$row['Resource_Id'];
$hint="<br/><font color='black'>The ID of this Resource Type is :".$id."<br/>";
$resultpp= mysql_query("SELECT * FROM resource_details Where Resource_Id='$id'");
if($rowpp = mysql_fetch_array($resultpp))
{
$hint=$hint."<br/>To view all <a href='".$basedir."/Resources/SearchRes.php?action=resource&r=".$id."' class='searchlinks'>".$q."</a>s' details<br/>";
}

$resultf= mysql_query("SELECT * FROM resource_details Where Resource_Id='$id' AND Functioning='Yes'");
if($rowf = mysql_fetch_array($resultf))
{
$hint=$hint."<br/>To view all <a href='".$basedir."/Resources/SearchRes.php?action=function&r=".$id."&f=Yes' class='searchlinks'>Functioning ".$q."</a>s' details<br/>";
}

$resultfn= mysql_query("SELECT * FROM resource_details Where Resource_Id='$id' AND Functioning='No'");
if($rowfn = mysql_fetch_array($resultfn))
{
$hint=$hint."<br/>To view all <a href='".$basedir."/Resources/SearchRes.php?action=function&r=".$id."&f=No' class='searchlinks'>inactive ".$q."</a>s' details<br/>";
}
$resultds = mysql_query("SELECT DISTINCT(School_Id) FROM resource_details Where Resource_Id='$id'");
while($rowds= mysql_fetch_array($resultds))
{
$Sc=$rowds['School_Id'];
$hint=$hint."<br/>To view all ".$q."s' details of all Labs of ";
$resultsc = mysql_query("SELECT * FROM school Where School_Id='$Sc'");
$hint=$hint.'<a href="'.$basedir.'/Resources/SearchRes.php?action=school&s='.$rowds['School_Id'].'&r='.$id.'" class="searchlinks">';
if(mysql_num_rows($resultsc)==0)
{
$hint=$hint.$Sc;
}
if(mysql_num_rows($resultsc)>0)
{
if($rowsc= mysql_fetch_array($resultsc))
{
$hint=$hint.$rowsc['Name'].' in '.$rowsc['Address'];
}
}
$hint=$hint.'</a><br/>';
}

$resultdb = mysql_query("SELECT DISTINCT(Brand_Name) FROM resource_details Where Resource_Id='$id'");
while($rowdb= mysql_fetch_array($resultdb))
{
$hint=$hint."<br/>To view all ";
$hint=$hint."<a href='".$basedir."/Resources/SearchRes.php?action=brand&r=".$id."&b=".$rowdb['Brand_Name']."'class='searchlinks'>".$rowdb['Brand_Name']."</a> ".$q."s' details<br/>";
}

$resultfs = mysql_query("SELECT DISTINCT(Funding_Source) FROM resource_details Where Resource_Id='$id'");
while($rowfs= mysql_fetch_array($resultfs))
{
$hint=$hint."<br/>To view all ";
$hint=$hint."".$q."s' details funded by <a href='".$basedir."/Resources/SearchRes.php?action=fundingsource&r=".$id."&fs=".$rowfs['Funding_Source']."'class='searchlinks'>".$rowfs['Funding_Source']."</a><br/>";
}
$hint=$hint.'</font>';
}
}
if($hint==''||$hint=="<br/><font color='black'>The ID of this Resource Type is :".$id."<br/></font>")
{
echo $hint."<br/>";
$response='<font class="err"><img src="../images/alert.jpg" width="12" height="12"/> There are no results found for this resource type!</font>';
}
else
{
$response=$hint;
}
echo $response;
?>